<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="__PUBLIC__/admin/css/style.css" rel="stylesheet" type="text/css" />
    <script language="JavaScript" src="__PUBLIC__/admin/js/jquery.js"></script>
</head>

<body>
    <div class="formbody">
        <div class="formtitle"><span>基本信息</span></div>
        <form action="" method="post">
            <span style="font-size: 16px">您正在给【<label style="color: red;font-weight: bolder;">{$info.role_name}</label>】设置权限</span><br>
            <ul class="forminfo">
                <table class="tablelist">
                    <thead>
                        <tr>
                            <th>权限分类</th>
                            <th>权限</th>
                        </tr>
                    </thead>
                    <tbody>
                        <volist name="topAuth" id="top">
                            <tr>
                                <td>
                                    <input <in name="top.auth_id" value="$info['role_auth_ids']">checked</in> type="checkbox" class="chk" name="auth_id[]" value="{$top.auth_id}">{$top.auth_name}
                                </td>
                                <td>
                                    <volist name="sonAuth" id="son">
                                    <if condition="$son['auth_pid'] eq $top['auth_id']">
                                    <input type="checkbox" <in name="son.auth_id" value="$info['role_auth_ids']">checked</in> class="child" name="auth_id[]" value="{$son.auth_id}">
                                    {$son.auth_name}&emsp;
                                    </if>
                                    </volist>
                                </td>
                            </tr>
                        </volist>
                    </tbody>
                </table>
                <br/>
                <li>
                    <label>&nbsp;</label>
                    <input name="role_id" type="hidden" value="{$info.role_id}" />
                    <input name="" id="btnSubmit" type="submit" class="btn" value="确认保存" />
                </li>
            </ul>
        </form>
    </div>
</body>
<script type="text/javascript">
//jQuery代码
$(function(){
    //给btnsubmit绑定点击事件
    $('#btnSubmit').on('click',function(){
        //表单提交
        $('form').submit();
    });
    //全选&反选
    $('.chk').click(function(){
    	var status = $(this).attr('checked');
    	if(status == 'checked'){
    		$(this).parent().parent().find("td:eq(1)").find("input").attr("checked","checked");
    	}else{
    		$(this).parent().parent().find("td:eq(1)").find("input").removeAttr("checked");
    	}
    });

    //补选父级
    $('.child').click(function(){
    	var currentChildStatus = $(this).attr('checked');
    	var _parent = $(this).parent().parent().find("td:eq(0)").find("input");
    	if(currentChildStatus == 'checked'){
    		_parent.attr("checked","checked");
    	}else{
    		var selectChkBox = $(this).parent().find(":checkbox:checked");
    		if(selectChkBox.length == '0'){
    			_parent.removeAttr("checked");
    		}
    	}
    });
});
</script>
</html>
